rm update
[EroBeats.git] / Djinn and Tonic - Erobeats / Animation.cpp
blob9b076ebbe7939f5afdec5ab862a11ace6a4c7e00
1 #include "Animation.h"
2 #include <iostream>
3 Animation::Animation()
6 animationSize = frames.size() - 1;
7 currentPosition = 0;
9 counter = 0;
10 gameFPS = 60;
12 done = false;
15 Animation::Animation(std::vector<SDL_Texture*> set)
17 frames = set;
18 animationSize = frames.size();
19 currentPosition = 0;
21 counter = 0;
22 gameFPS = 60;
24 done = false;
28 Animation::~Animation()
33 SDL_Texture* Animation::itterateAnimation(int framerate) {
34 counter++;
35 //std::cout << counter << " ";
36 SDL_Texture* frame = frames.at(currentPosition);
37 if (counter > gameFPS / framerate) {
38 previousPosition = currentPosition;
39 currentPosition++;
40 if (currentPosition > animationSize - 1) {
41 done = true;
42 currentPosition = 0;
44 counter = 0;
46 return frame;
49 void Animation::destroyAnimation() {
50 int frameSize = frames.size();
51 for (int i = 0; i < frameSize; i++) {
52 SDL_DestroyTexture(frames.at(i));
56 void Animation::resetAnimation() {
57 currentPosition = 0;
60 bool Animation::checkDone(){
61 if (done) {
62 done = false;
63 return true;
65 else {
66 return false;